package ${packageName};

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.Calendar;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import org.easypeas.annotations.Action;
import org.easypeas.annotations.EasyPea;
import org.easypeas.annotations.View;

@EasyPea(name="test")
public class Test {
    @View(name="index")
    public void index(HttpServletRequest req, HttpServletResponse resp, Map<String,Object> map) {
        map.put("serverinfo", req.getSession().getServletContext()
        .getServerInfo());
        
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss 'UTC'");
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        map.put("date", format.format(new Date()).toString());
    }
    
    @Action(name="givename",forwards={"success=/test/sayhello.vm","failure=/error.vm"})
    public String giveName(HttpServletRequest req, HttpServletResponse resp, Map<String,Object> map) {
        String name=req.getParameter("thename");
        map.put("name",name);
        
        return "success";
    }
}
